package com.hunan.yllxy.controller;

import com.hunan.yllxy.exceptions.CustomerException;
import com.hunan.yllxy.repostitory.entity.*;
import com.hunan.yllxy.service.MainService;
import com.hunan.yllxy.vo.PageQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: 刘华
 * @Date: 2025/6/16 下午8:41
 * @Version 1.0
 */
@RestController
@Api(tags = "主要服务接口", value = "主要服务接口")
@RequestMapping("/api/main")
public class MainController {
@Autowired
private MainService mainService;

    @PostMapping("testApp1")
    @ApiOperation("测试应用1")
    public void testApp1() {
        mainService.testApp1();
    }
    @ApiOperation("添加或更新普通用户")
    @PostMapping( value = "addSimpleUser")
    public void addSimpleUser(@RequestBody UserInfo userInfo) {
        mainService.addSimpleUser(userInfo);
    }

    @ApiOperation("用户更新")
    @PostMapping( value = "updateUser")
    public void updateUser(@RequestBody UserInfo userInfo) {
        mainService.updateUser(userInfo);
    }

    @ApiOperation("用户删除")
    @PostMapping( value = "deleteUser")
    public void deleteUser(String userId) {
        mainService.deleteUser(userId);
    }

    @ApiOperation("添加管理员用户")
    @PostMapping( value = "addAdminUser")
    public void addAdminUser(@RequestBody UserInfo userInfo) {
        mainService.addAdminUser(userInfo);
    }

    @ApiOperation("导出用户")
    @PostMapping( value = "exportUser",produces = "application/octet-stream")
    public void exportUser(HttpServletResponse response) {
        mainService.exportUser(response);
    }

    @ApiOperation("查询用户列表")
    @PostMapping( value = "userList")
    public ResponseEntity exportUseruserList(PageQuery pageQuery,String roleId) {
        return mainService.userList(pageQuery,roleId);
    }


    @ApiOperation("添加或更新活动")
    @PostMapping( value = "addActivityData")
    public ResponseEntity addActivityData(@RequestBody ActivityInfo activityInfo) {
        return mainService.addActivityData(activityInfo);
    }

    @ApiOperation("查询活动")
    @PostMapping( value = "queryActivity")
    public ResponseEntity queryActivity() {
      return   mainService.queryActivity();
    }
    @ApiOperation("删除活动")
    @PostMapping( value = "deleteActivity")
    public ResponseEntity deleteActivity(String activityId) {
       return mainService.deleteActivity(activityId);
    }
    @ApiOperation("获取最新活动")
    @PostMapping( value = "lastActivity")
    public ResponseEntity lastActivity() {
       return mainService.lastActivity();
    }

    @ApiOperation("能量站添加或更新")
    @PostMapping( value = "addOrUpdatePowerStation")
    public ResponseEntity addOrUpdatePowerStation(@RequestBody PowerStation powerStation) {
        return mainService.addOrUpdatePowerStation(powerStation);
    }

    @ApiOperation("能量站删除")
    @PostMapping( value = "deletePowerStation")
    public ResponseEntity deletePowerStation( String powerStationId) {
        return mainService.deletePowerStation(powerStationId);
    }

    @ApiOperation("能量站查询")
    @PostMapping( value = "powerStationQuery")
    public ResponseEntity powerStationQuery(PageQuery pageQuery) {
        return mainService.powerStationQuery(pageQuery);
    }

    @ApiOperation("能量站查询已发布")
    @PostMapping( value = "powerStationQueryPublish")
    public ResponseEntity powerStationQueryPublish(PageQuery pageQuery) {
        return mainService.powerStationQueryPublish(pageQuery);
    }

    @ApiOperation("资料添加或更新")
    @PostMapping( value = "addOrUpdateMaterialsStation")
    public ResponseEntity addOrUpdateMaterialsStation(@RequestBody MaterialsStation materialsStation) {
        return mainService.addOrUpdateMaterialsStation(materialsStation);
    }


    @ApiOperation("资料导入")
    @PostMapping( value = "importMaterialsStation")
    public ResponseEntity importMaterialsStation(MultipartFile multipartFile) {
        return mainService.importMaterialsStation(multipartFile);
    }

    @ApiOperation("资料删除")
    @PostMapping( value = "deleteMaterialsStation")
    public ResponseEntity deleteMaterialsStation(String materialsStationId) {
        return mainService.deleteMaterialsStation(materialsStationId);
    }

    @ApiOperation("资料查询")
    @PostMapping( value = "materialsStationQuery")
    public ResponseEntity materialsStationQuery( ) {
        return mainService.materialsStationQuery();
    }

    @ApiOperation("添加分数")
    @PostMapping( value = "addOrUpdateScore")
    public ResponseEntity addOrUpdateScore(@RequestBody DakaScoreInfo dakaScoreInfo ) {
        return mainService.addOrUpdateScore(dakaScoreInfo);
    }

    @ApiOperation("查询分数")
    @PostMapping( value = "queryScore")
    public ResponseEntity queryScore( String activityId ) {
        return mainService.queryScore(activityId);
    }

    @ApiOperation("删除分数")
    @PostMapping( value = "deleteScore")
    public ResponseEntity deleteScore( String id ) {
        return mainService.deleteScore(id);
    }

    @ApiOperation("添加打卡内容")
    @PostMapping( value = "addContent")
    public ResponseEntity addContent(@RequestBody DakaContentInfo dakaContentInfo ) {
        return mainService.addContent(dakaContentInfo);
    }

    @ApiOperation("删除打卡内容")
    @PostMapping( value = "deleteContent")
    public ResponseEntity deleteContent(String id ) {
        return mainService.deleteContent(id);
    }

    @ApiOperation("查询打卡内容")
    @PostMapping( value = "queryContent")
    public ResponseEntity queryContent( String activityId ) {
        return mainService.queryContent(activityId);
    }

    @ApiOperation("用户查询打卡内容")
    @PostMapping( value = "userQueryContent")
    public ResponseEntity userQueryContent( String activityId ) {
        return mainService.userQueryContent(activityId);
    }
    @ApiOperation("添加打卡选项")
    @PostMapping( value = "addOption")
    public ResponseEntity addOption(@RequestBody DakaOptionInfo dakaOptionInfo ) {
        return mainService.addOption(dakaOptionInfo);
    }
    @ApiOperation("删除打卡选项")
    @PostMapping( value = "deleteOption")
    public ResponseEntity deleteOption( String id ) {
        return mainService.deleteOption(id);
    }

    @ApiOperation("查询打卡选项")
    @PostMapping( value = "queryOption")
    public ResponseEntity queryOption( String contentId ) {
        return mainService.queryOption(contentId);
    }

    @ApiOperation("用户待打卡内容")
    @PostMapping( value = "dakaContent")
    public ResponseEntity dakaContent(String activityId ) {
        return mainService.dakaContent(activityId);
    }

    @ApiOperation("用户打卡")
    @PostMapping( value = "daka")
    public ResponseEntity daka(@RequestBody UserDakaInfo userDakaInfo ) {
        return mainService.daka(userDakaInfo);
    }

    @ApiOperation("用户打卡记录")
    @PostMapping( value = "dakaRecord")
    public ResponseEntity dakaRecord(String activityId ) {
        return mainService.dakaRecord(activityId);
    }

    @ApiOperation("多用户打卡记录")
    @PostMapping( value = "userDakaRecord")
    public ResponseEntity userDakaRecord(String activityId ,PageQuery pageQuery) {
        return mainService.userDakaRecord(activityId,pageQuery);
    }

    @ApiOperation("柱状图")
    @PostMapping( value = "histogram")
    public ResponseEntity histogram(String activityId ) {
        return mainService.histogram(activityId);
    }

    @ApiOperation("折线图")
    @PostMapping( value = "brokenLineGraph")
    public ResponseEntity brokenLineGraph(String activityId) {
        return mainService.brokenLineGraph(activityId);
    }

    @ApiOperation("折线图2")
    @PostMapping( value = "brokenLineGraph2")
    public ResponseEntity brokenLineGraph2(String activityId,String contentId) {
        return mainService.brokenLineGraph2(activityId,contentId);
    }

    @ApiOperation("查看用户打卡记录")
    @PostMapping( value = "queryUserRecord")
    public ResponseEntity queryUserRecord(PageQuery pageQuery,String userId,String activityId,String dakaContentId,String dakaOptionId) {
        return mainService.queryUserRecord(pageQuery,userId,activityId,dakaContentId,dakaOptionId);
    }

    @ApiOperation("导出用户打卡记录")
    @PostMapping( value = "exportQueryUserRecord",produces = "application/octet-stream")
    public void exportQueryUserRecord(String userId,String activityId,String dakaContentId,String dakaOptionId,HttpServletResponse response ) {
         mainService.exportQueryUserRecord(userId,activityId,dakaContentId,response,dakaOptionId);
    }


}
